package com.example.leetdemo.finash;

import java.util.Arrays;
import java.util.Comparator;

public class Solution6200 {
    public int hardestWorker(int n, int[][] logs) {
        int h = logs[0][0], time = logs[0][1];
        Arrays.sort(logs, Comparator.comparingInt(o -> o[1]));
        for (int i = 1; i < logs.length; i++) {
            if (logs[i][1] - logs[i - 1][1] > time) {
                h = logs[i][0];
                time = logs[i][1] - logs[i - 1][1];
            }
            if (logs[i][1] - logs[i - 1][1] == time) {
                h = Math.min(logs[i][0], h);
            }
        }
        return h;
    }

    public static void main(String[] args) {
        Solution6200 solution6200 = new Solution6200();
        System.err.println(solution6200.hardestWorker(26,
                new int[][] {{0,3},{2,5},{0,9},{1,15 }}));
    }
}
